/**
 * 
 */
package com.macasa.service.dal.api;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Criteria;

import com.macasa.panel.dao.hibernate.api.IDao;
import com.macasa.panel.entity.api.IModel;
import com.macasa.panel.exception.DALException;

/**
 * Interface ICRUDSService
 * <P>
 * 
 * @param <ID>
 * @param <DTO>
 * @author Mickaël Husson
 * @date 01/01/2012
 */
public interface ICRUDDal<DTO extends IModel<ID>, ID extends Serializable> extends Serializable {

	/**
	 * @param id
	 *            ID
	 * @throws DALException
	 */
	void create(DTO id) throws DALException;

	/**
	 * @param id
	 *            ID
	 * @throws DALException
	 */
	void delete(DTO id) throws DALException;

	/**
	 * @param id
	 *            ID
	 * @throws DALException
	 */
	void evict(DTO id) throws DALException;

	/**
	 * @throws DALException
	 */
	void flush() throws DALException;

	/**
	 * @return all List<ID>
	 * @throws DALException
	 */
	List<DTO> getAll() throws DALException;

	/**
	 * @param firstResult
	 *            int
	 * @param maxResults
	 *            int
	 * @return all List<ID>
	 * @throws DALException
	 */
	List<DTO> getAll(int firstResult, int maxResults) throws DALException;

	/**
	 * @param criteria
	 *            Criteria
	 * @return all List<DTO>
	 * @throws DALException
	 */
	List<DTO> getFromCriteria(final Criteria criteria) throws DALException;

	/**
	 * @return all List<ID_TYPE>
	 * @throws DALException
	 */
	List<ID> getAllId() throws DALException;

	/**
	 * @return all number Integer
	 * @throws DALException
	 */
	Integer getAllNumber() throws DALException;

	/**
	 * @return aO IGenericDAO<ID, ID_TYPE>
	 */
	IDao<DTO, ID> getDao();

	/**
	 * @param id
	 *            ID_TYPE
	 * @return id ID
	 * @throws DALException
	 */
	DTO getFromID(ID id) throws DALException;

	/**
	 * @param ids
	 *            List
	 * @return all List<DTO>
	 * @throws DALException
	 */
	List<DTO> getFromIDS(List<ID> ids) throws DALException;

	/**
	 * @param query
	 *            String
	 * @param paramValues
	 *            Object[]
	 * @return all List<DTO>
	 * @throws DALException
	 */
	List<DTO> getFromQuery(final String query, final Object[] paramValues) throws DALException;

	/**
	 * @param attributeName
	 *            String
	 * @param value
	 *            Object
	 * @return all List<DTO>
	 * @throws DALException
	 */
	List<DTO> getFromAttribute(final String attributeName, final Object value) throws DALException;

	/**
	 * @param attributeName
	 *            String
	 * @param value
	 *            List<Object>
	 * @return all List<DTO>
	 * @throws DALException
	 */
	List<DTO> getFromAttributes(final String attributeName, final List<? extends Object> values) throws DALException;

	/**
	 * @param typeDao
	 *            IGenericDAO<ID, ID_TYPE>
	 */
	void setDao(IDao<DTO, ID> typeDao);

	/**
	 * @param id
	 *            ID
	 * @throws DALException
	 */
	void update(DTO id) throws DALException;
}
